package com.qiaofang.common.utils;

import lombok.Data;

@Data
public class Context {

    private static final ThreadLocal<Context> THREAD_LOCAL = new ThreadLocal();

    private Long userId;

    private String userUuid;

    private String token;

    public static void setThreadLocal(Context context) {
        THREAD_LOCAL.set(context);
    }

    public static ThreadLocal<Context> getThreadLocal() {
        return THREAD_LOCAL;
    }

    public Context(Long userId, String userUuid, String token) {
        this.userId = userId;
        this.userUuid = userUuid;
        this.token = token;
    }

    public static void removeContextThreadLocal() {
        THREAD_LOCAL.remove();
    }
}
